﻿using System.Net;
using System.Net.Http;
using Sustainalytics.Insights.Service.Dto;
using System;
using System.Web.Http;
using Sustainalytics.Utils;
using System.Web.Http.Cors;

namespace Sustainalytics.Insights.Service
{
    [EnableCors(origins: "*", headers: "*", methods: "*")]
    //[AutoInvalidateCacheOutput]
    [RoutePrefix("api/v1/insightsnames")]
    [LogControllerFilter(true, true, false)]
	public class InsightsNamesController : ApiController, IInsightsNamesController
	{
        private readonly IHelperRepository _repository;

        public InsightsNamesController(IHelperRepository repository)
        {
            this._repository = repository;
        }

       // [CacheOutput(ServerTimeSpan = 100, ClientTimeSpan = 0, NoCache = true, MustRevalidate = true, Private = true)]
        public HttpResponseMessage Get()
		{
            try
            {           
                var result = new InsightHelperDto();
                result.SectorNames = _repository.GetSectorsName();
                result.TopicNames = _repository.GetTopicsName();
                return Request.CreateResponse(HttpStatusCode.OK, result);
            }
            catch (Exception)
            {
                return Request.CreateResponse(HttpStatusCode.InternalServerError);
            }
		   
		}

	}
}

